<?php
	$conn = mysql_connect('localhost','root','');
	mysql_select_db('admin_crm');
	mysql_query("set names 'utf8'");

	function change_spayment($str){
		$sql = 'select `id`,`'.$str.'` cs from `student_payment_record` where is_removed=0 and `'.$str.'` not like "%-%"';
		$row = mysql_query($sql);
		$up_sql = '';
		while ($ret = mysql_fetch_array($row)){
			if(strpos($ret['cs'],'/')){
				$date = explode('/',$ret['cs']);
				$date1 = $date[2].'-'.$date[1].'-'.$date[0];
				$up_sql = 'update `student_payment_record` set `'.$str.'`=\''.$date1.'\' where id='.$ret['id'];
			}else if(strpos($ret['cs'],',')){
				$up_sql = 'update `student_payment_record` set `'.$str.'`=\''.date("Y-m-d",strtotime($ret['cs'])).'\' where id='.$ret['id'];
			}else{
				$up_sql = 'update `program_student_course` set `'.$str.'`=\'0000-00-00\' where id='.$ret['id'];
			}
			//echo $up_sql."\n";
			mysql_query($up_sql);
		}
	}

	change_spayment('date1');
	change_spayment('date2');
	change_spayment('date3');
	change_spayment('date4');
	change_spayment('date1_paid');
	change_spayment('date2_paid');
	change_spayment('date3_paid');
	change_spayment('date4_paid');

	mysql_close($conn);
	//echo date('Y-m-d',strtotime('10/20/2001'))
?>